package com.jgj.zxkj.lookandcheckjggroupinfo.record.home;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;

import com.jgj.zxkj.lookandcheckjggroupinfo.R;
import com.jgj.zxkj.lookandcheckjggroupinfo.login.SignInDelegate;
import com.jgj.zxkj.lookandcheckjggroupinfo.record.checking.CheckingDelegate;
import com.jgj.zxkj.lookandcheckjggroupinfo.record.finishcheck.FinishCheckDelegate;
import com.jgj.zxkj.lookandcheckjggroupinfo.record.nocheck.NoCheckDelegate;
import com.jgj.zxkj.lookandcheckjggroupinfo.record.nopasscheck.NoPassCheckDelegate;
import com.sa.all_cui.mix_core.delegate.bottom.BottomItemDelegate;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by all-cui on 2017/10/27.
 */
public class HomeDelegate extends BottomItemDelegate {
    @BindView(R.id.tbl_delegate_finish_check)
    TabLayout mTbIndicate = null;
    @BindView(R.id.vp_delegate_finish_check)
    ViewPager mVp = null;
    @BindView(R.id.tv_toolbar_title)
    AppCompatTextView mTitle = null;

    @Override
    public Object setLayout() {
        return R.layout.delegate_home;
    }

    private void initViewPager() {
        final List<Fragment> fragments = new ArrayList<>();
        fragments.add(new NoCheckDelegate());
        fragments.add(new CheckingDelegate());
        fragments.add(new FinishCheckDelegate());
        fragments.add(new NoPassCheckDelegate());
        final HomeViewPagerAdapter adapter = new HomeViewPagerAdapter(getChildFragmentManager(), fragments);
        mVp.setAdapter(adapter);
        mVp.setOffscreenPageLimit(4);
        //将tableLayout与ViewPagerAdapter关联起来
        mTbIndicate.setupWithViewPager(mVp);
    }


    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View view) {
        mTitle.setText(R.string.bottom_home_value);
        initViewPager();
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        changeStatusBarColor(R.color.colorDeepSea);
    }
}
